home *** CD-ROM | disk | FTP | other *** search
- /* BoxMooV_QuickTime.c
- *
- * Rick Evans Sept. 1996
- * Robert Dierkes
- * (c)1994-96 Apple Computer Inc., All Rights Reserved
- *
- */
-
- /*------------------*/
- /* Include Files */
- /*------------------*/
- #include <Memory.h>
- #include <Movies.h>
- #include <QDOffscreen.h>
-
- #include "QD3D.h"
- #include "QD3DStorage.h"
-
- #include "BoxMoov_QuickTime.h"
-
- /*===========================================================================*\
- *
- * Routine: QuickTime_Init()
- *
- * Comments: Intialize QuickTime Toolbox.
- *
- *
- \*===========================================================================*/
-
- void QuickTime_Init(
- void)
- {
- EnterMovies();
- }
-
-
-
- /*===========================================================================*\
- *
- * Routine: QuickTime_Delete()
- *
- * Comments: Stop movie playback, and dispose of its memory
- *
- *
- \*===========================================================================*/
-
- void QuickTime_Delete(
- Movie *moviePtr)
- {
- if (*moviePtr != NULL)
- {
- StopMovie(*moviePtr);
- DisposeMovie(*moviePtr);
- ExitMovies();
- *moviePtr = NULL;
- }
- }
-
- /*===========================================================================*\
- *
- * Routine: QuickTime_GetNewMooVTexture()
- *
- * Comments: Query user for a MooV File, and set up animated texture
- *
- *
- \*===========================================================================*/
-
- Boolean QuickTime_GetNewMooVTexture(
- Movie *theMovie)
- {
- StandardFileReply reply;
- short numTypes = 1 ;
- SFTypeList myTypes = { 'MooV', 0 } ;
-
- /* Clean up any previous movie */
- if (*theMovie != NULL)
- QuickTime_Delete( theMovie );
-
- /* Get movie file from user */
- StandardGetFilePreview(nil, numTypes, myTypes, &reply);
-
- if ( ! reply.sfGood )
- return (false);
-
- return (QuickTime_LoadMovie(&reply.sfFile, theMovie));
- }
-
- /*===========================================================================*\
- *
- * Routine: QuickTime_LoadMovie()
- *
- * Comments: Takes a FSSpec and loads a movie into a TQ3StoragePixmap structure
- *
- \*===========================================================================*/
-
- Boolean QuickTime_LoadMovie(
- FSSpec *pFile,
- Movie *pMovie)
- {
- QDErr err;
- short fref;
- Rect bounds;
-
- /* Load movie */
- err = OpenMovieFile(pFile, &fref, fsRdPerm);
- if (err) return false;
-
- err = NewMovieFromFile(pMovie, fref, nil, (StringPtr)nil, newMovieActive, nil);
- if (err) return false;
-
- CloseMovieFile(fref);
-
- /* Figure out movie dimensions */
- /* Set movie to identity matrix. we hope this means "its natural size" */
- SetMovieMatrix(*pMovie, nil);
-
- // GetMovieBox(*pMovie, &bounds);
- // OffsetRect(&bounds, -bounds.left, -bounds.top);
-
- SetRect(&bounds, 0, 0, 128, 128);
- SetMovieBox(*pMovie, &bounds);
-
- return true;
-
- }
-
-
- /*===========================================================================*\
- *
- * Routine: QuickTime_LoopMovie()
- *
- * Comments: Start movie playing in a loop
- *
- *
- \*===========================================================================*/
-
- void QuickTime_LoopMovie(Movie pMovie, GWorldPtr pGWorld)
- {
- TimeBase timeBase;
-
- SetMovieGWorld(pMovie, pGWorld, nil);
-
- /* Draw the movie first */
- MoviesTask(pMovie, 0);
- MoviesTask(pMovie, 0);
-
- /* throw the movie into loop mode */
- timeBase = GetMovieTimeBase(pMovie);
- SetTimeBaseFlags(timeBase, GetTimeBaseFlags(timeBase) | loopTimeBase);
-
- /* start the movie a' playin' */
- StartMovie(pMovie);
- }
-